package com.ruoyi.production.service.impl.graftinglabel;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.order.domain.OrderAllocation;
import com.ruoyi.order.mapper.OrderAllocationMapper;
import com.ruoyi.production.domain.graftinglabel.GraftinglabelApply;
import com.ruoyi.production.mapper.graftinglabel.GraftinglabelApplyMapper;
import com.ruoyi.production.service.graftinglabel.IGraftinglabelApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 嫁接签申请Service业务层处理
 *
 * @author ruoyi
 * @date 2021-07-11
 */
@Service
public class GraftinglabelApplyServiceImpl implements IGraftinglabelApplyService
{
    @Autowired
    private GraftinglabelApplyMapper graftinglabelApplyMapper;
    @Autowired
    private OrderAllocationMapper orderAllocationMapper;

    /**
     * 查询嫁接签申请
     *
     * @param graftinglabelApplyId 嫁接签申请ID
     * @return 嫁接签申请
     */
    @Override
    public GraftinglabelApply selectGraftinglabelApplyById(Long graftinglabelApplyId)
    {
        return graftinglabelApplyMapper.selectGraftinglabelApplyById(graftinglabelApplyId);
    }

    /**
     * 查询嫁接签申请列表
     *
     * @param graftinglabelApply 嫁接签申请
     * @return 嫁接签申请
     */
    @Override
    public List<GraftinglabelApply> selectGraftinglabelApplyList(GraftinglabelApply graftinglabelApply)
    {
        return graftinglabelApplyMapper.selectGraftinglabelApplyList(graftinglabelApply);
    }

    /**
     * 新增嫁接签申请
     *
     * @param graftinglabelApply 嫁接签申请
     * @return 结果
     */
    @Override
    public int insertGraftinglabelApply(GraftinglabelApply graftinglabelApply)
    {
        Long orderAllocationId = graftinglabelApply.getOrderAllocationId();
        OrderAllocation orderAllocation = orderAllocationMapper.selectOrderAllocationById(orderAllocationId);
        graftinglabelApply.setOrderId(orderAllocation.getOrderId());













        graftinglabelApply.setCreateTime(DateUtils.getNowDate());



        return graftinglabelApplyMapper.insertGraftinglabelApply(graftinglabelApply);
    }

    /**
     * 修改嫁接签申请
     *
     * @param graftinglabelApply 嫁接签申请
     * @return 结果
     */
    @Override
    public int updateGraftinglabelApply(GraftinglabelApply graftinglabelApply)
    {
        graftinglabelApply.setUpdateTime(DateUtils.getNowDate());
        return graftinglabelApplyMapper.updateGraftinglabelApply(graftinglabelApply);
    }

    /**
     * 批量删除嫁接签申请
     *
     * @param graftinglabelApplyIds 需要删除的嫁接签申请ID
     * @return 结果
     */
    @Override
    public int deleteGraftinglabelApplyByIds(Long[] graftinglabelApplyIds)
    {
        return graftinglabelApplyMapper.deleteGraftinglabelApplyByIds(graftinglabelApplyIds);
    }

    /**
     * 删除嫁接签申请信息
     *
     * @param graftinglabelApplyId 嫁接签申请ID
     * @return 结果
     */
    @Override
    public int deleteGraftinglabelApplyById(Long graftinglabelApplyId)
    {
        return graftinglabelApplyMapper.deleteGraftinglabelApplyById(graftinglabelApplyId);
    }
}
